  var object={};
  var totalPage=0; 
  var page=1;
  var information={state:1};
  var chooseId;
  var insertid;
$(function(){
  var endId=[];
  var insertid;
  var deleteid;
  requestRefer();//已提交数据  
  	//查询
	$("#firstSearch").click(function() {
		firstSearch();
	})
  
  
  
   //跳转到点评页面
	$(document).on("click",".update",function(){
		 var id= $(this).attr("data-id");
		 var flowId= $(this).attr("data-flowId");
		var menuId=$("#menu-container").attr("menu-id");
		 window.location.href='commentDetail.jsp?detailId=' + id;
	});
	
	//分页，首页
	  $("#headPage").click(function(){
	  	page=1;
	  	$("#totalPage").html(page+"/"+totalPage);
	  	requestPage(page);
	  })
	  //分页，尾页
	  $("#endPage").click(function(){
	  	$("#totalPage").html(totalPage+"/"+totalPage);
	  	page=totalPage;
	  	requestPage(page);
	  })
	  //分页，上一页
	  $("#prevPage").click(function(){
	  	if(page<=1)
	  	{
	  		page=1;
	  	}
	  	else
	  	{
	  		page=page-1;
	  		$("#totalPage").html(page+"/"+totalPage);
	  		requestPage(page);
	  	}

	 })
	  //分页，下一页
	   $("#nextPage").click(function(){  
	  	if(page>=totalPage)
	  	{
	  		page=page-1;  		
	  	}
	  	else
	  	{
	  		page=page+1;
	  		$("#totalPage").html(page+"/"+totalPage);
	  		requestPage(page);
	  	}
	  	return false;
	  	
	  });


//分页
function requestPage(page)
  {$("#tablebody").html("");
	 if(information!=null){
		 information.currentPage=page;
		 var url="getQueryPoleceTableList.do";//地址----------------------------------
		  YuXi.util.get(url,information,function(data){
			  	//console.log(data);
			  	page=data.currentPage;
				totalPage=data.totalPage;
				$("#totalPage").html(page+"/"+totalPage);
				object=data.list;
			  	$("#tablebody").html("");		
			  	setData(object);
				
			},function(){
				//console.log("查询失败");
			});
	 }
	 else{
		 var dapage={currentPage:page};
			var url="getQueryPoleceTableList.do";
			/*------*/								
			YuXi.util.get(url,dapage,function(data){
				//console.log(data);
				page=data.currentPage;
				totalPage=data.totalPage;
				$("#totalPage").html(page+"/"+totalPage);
				object=data.list;
				setData(object);
			 },function(){
				 //console.log("分页出错");
			 })
	 }
}

//向后台请求已提交的信息数据
function requestRefer()
{
	var url="getQueryPoleceTableList.do";
	YuXi.util.get(url,information,function(data){
		object=data.list;		
		setData(object);
		page=data.currentPage;
		totalPage=data.totalPage;
		$("#totalPage").html(page+"/"+totalPage);
	},function(){});
}

//查找
function firstSearch()
{
	if($("#roleName").val()!=null&&$("#roleName").val()!="")
		var userNa=$("#roleName").val();
		if(userNa!='请输入AB角'&&userNa!=""){
			information.userAB=userNa
		}
		
	//var value=$(".valTime option:selected").val();
	var array=[];
	var starTime=$("#starTime").val();
	var endTime=$("#endTime").val();
	array=YuXi.timestamp.get(starTime,endTime,null);	
	if(array[0]!=null){
		information.startTime=array[0];
		
	}
	if(array[1]!=null){
		information.endTime=array[1];
	}
	//查询数据传送给后台
	 var url="getQueryPoleceTableList.do";//地址----------------------------------
	  YuXi.util.get(url,information,function(data){
		  	//console.log(data);
	  		totalPage=data.totalPage;
	  		$("#totalPage").html("1/"+totalPage);
		  	var object=data.list;
		  	page=data.currentPage;
			totalPage=data.totalPage;
			$("#totalPage").html(page+"/"+totalPage);
		  	$("#tablebody").html("");
		
		  	setData(object);
			
		},function(){
			//console.log("查询失败");
		});
}




function setData(object){
	//模拟数据
	for(var i=0;i<object.length;i++)
	{	
		//console.log(object);
		var time=YuXi.getTime.get(object[i].createTime);	
		var uB=object[i].userBName;
		if(isNull(uB)){
			uB="";
		}
		
		var detail="<a  data-word='"+object[i].wordAddress+"' href='commentDetail.jsp?id="+object[i].id+"&htmlAddress="+object[i].htmlAddress+"'>评价</a>";
		if(object[i].state==1){
			detail="<a  data-word='"+object[i].wordAddress+"' href='commentDetailA.jsp?id="+object[i].id+"&htmlAddress="+object[i].htmlAddress+"'>详情</a>";
		}
		var html="<tr>"+
		"					<th>"+object[i].id+"</th>"+
		"					<th >"+object[i].createUserName+"</th>"+
		"					<th >"+uB+"</th>"+
		"					<th >"+time+"</th>				"+
		"					<th><a href='/yuxi/"+object[i].wordAddress+"'>导出word文档</a> &nbsp"+detail+"</th>"+
		"				</tr>";
		$("#tablebody").append(html);	
	}
	YuXi.graded.get();	

}

function isNull(str){	
	if(str==null||str==""){
		return false;
	}else{
		return true;
	}
}
})